# -*- coding: utf-8 -*- 
# @project : 《Atcoder》
# @Author : created by bensonrachel on 2021/11/26
# @File : offer55. 连续子数组的最大和.py

def tpm():
    #滑动窗口双指针的做法
    sum_ = 0
    max_ = -10000000
    l = 0
    r = 0
    while r<n:
        sum_ += a[r]
        if sum_>=max_:
            max_ = sum_
        while sum_ < 0 and l<=r:
            sum_ -= a[l]
            l += 1
        max_ = max(sum_,max_)
        r += 1
        #特判全为负数的情况。
        if l==r and l==n and max_==0:
            max_ = max(a)
    return max_

def dp_solve():
    #dp[i] 代表以元素 nums[i] 为结尾的连续子数组最大和
    dp = [0]*(n)
    dp[0] = a[0]
    for i in range(1,n):
        dp[i] = max(dp[i-1]+a[i],a[i])
    return max(dp)

def Greed_solve():
    #贪心做法。
    sum_ = 0
    max_ = -10000000
    for item in a:
        sum_ += item
        max_ = max(max_,sum_)
        if sum_<0:
            sum_ = 0
    return max_


if __name__ == '__main__':
    a = list(map(int,input().split()))
    n = len(a)
    ans = tpm()
    print(ans)

